Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 2 - Finder Objects / Object Class Definitions


Item

An object of class Item is any item in a container.

PROPERTIES
bounds
The coordinates of the rectangle that bounds the content region of the item's icon.
Class: List of four integers (Bounding Rectangle data type).
The first two integers specify the coordinates of the upperleft corner of the item's icon, and the last two integers specify the coordinates of the lower-right corner of the icon.
Modifiable? Yes
comment
The comment displayed in the item's information window.
Class: String
Modifiable: Yes
container
A reference to the container in which the item is located.
Class: Reference
Modifiable: No
content space
A reference to the content space that opens when the item
is opened.
Class: Content Space
Modifiable: No
creation date
The date on which the item was created.
Class: Date
Modifiable: No
disk
A reference to the disk on which the item is stored.
Class: Reference
Modifiable: No
folder
A reference to the folder, if any, in which the item is stored.
Class: Reference
Modifiable: No
icon
A bitmap of the item's icon.
Class: Icon family (data type defined by Finder)
Modifiable: Yes
id
The item's hierarchical file system (HFS) ID number, an integer that identifies an application file, folder, or disk. (For examples of the use of this property, see page 35.)
Class: Integer
Modifiable: No
information window
A reference to the item's information window.
Class: Reference
Modifiable: No
kind
The kind of item as listed under Kind in the item's
container window.
Class: String
Modifiable: No
label index
The number of the label currently selected for the item in the Label menu (None = 0).
Class: Integer
Modifiable: Yes
modification date
The date on which the item was most recently modified.
Class: Date
Modifiable: No
name
The item's name.
Class: String
Modifiable: Yes
physical size
The physical size of the item on disk, in bytes.
Class:
Integer
Modifiable: No
position
Two integers that specify the position of the upper-left corner of the item's icon.
Class: List of two integers (Point data type)
Modifiable? Yes
selected
A Boolean value that indicates whether the item is selected (true) or not (false).
Class: Boolean
Modifiable: Yes
size
The logical size of the item on disk, in bytes.
Class: Integer
Modifiable: No
window
A reference to the window that opens when the item is opened.
Class: Reference
Modifiable: No
ELEMENT CLASSES
None

COMMANDS HANDLED
Clean Up, Close, Copy, Count, Data Size, Delete, Duplicate, Exists, Get, Move, Open, Put Away, Reveal, Select, Sort, Update

DEFAULT VALUE CLASS RETURNED
A reference to a file, folder, disk, the Trash, or the desktop or, if you use the plural form items, a list of references.

EXAMPLES
The script that follows moves a group of items that start with an at (@) symbol back and forth between the Apple Menu Items folder and a folder at the top level of the startup disk called Apple Menu Extras.

To work correctly, this script must be stored as a script application at the top level of the startup disk; the startup disk must also contain a folder called Apple Menu Extras to store the items you want to move in and out of the Apple Menu Items folder; and the names of the items in the Apple Menu Items folder must all begin with an @ symbol. It is also important, as with any script, to have some free memory available in addition to the memory used by any currently running processes--preferably several hundred kilobytes.

property Extras : false

tell application "Finder"
   if (exists item " Add Extras" of apple menu items folder) ¬
      = false and ¬
      (exists item " Remove Extras" of apple menu items folder) ¬
         = false then
      make alias file with data (file "Toggle Apple Menu Extras" of ¬
         startup disk) at apple menu items folder ¬
         with properties {name:" Add Extras"}
   end if
   
   if Extras is false then
      move contents of folder "Apple Menu Extras" of startup disk to ¬
         apple menu items folder
      set the name of item " Add Extras" in apple menu items folder ¬
         to " Remove Extras"      set Extras to true
   else
      move (every item of apple menu items folder ¬
         whose name begins with "@") to ¬
         folder "Apple Menu Extras" of startup disk
      set the name of item " Remove Extras" in ¬
         apple menu items folder to " Add Extras"      set Extras to false
   end if
   
end tell
The script begins by declaring the value of the Extras property to be false. This value may change after the script is run.

If the script hasn't been run before, the first If statement in the script creates an alias file of the script application in the Apple Menu Items folder with the name Add Extras. This alias file appears in the Apple menu along with all the other items in the Apple Menu Items folder, and its name changes to Remove Extras after the extra items have been added to that folder.

If the value of Extras is false, the first part of the second If statement moves the contents of the Apple Menu Extras folder into the Apple Menu Items folder, changes the name of the alias file to Remove Extras, and sets the value of Extras to true.

If the value of Extras is true, the second part of the second If statement moves all items in the Apple Menu Items folder that begin with an @ symbol into the Apple Menu Extras folder, changes the name of the alias file to Add Extras, and sets the value of Extras to false.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996